﻿using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Logic.Interface;
using System.Collections;
using Meqs.Entity;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public string GetLoginInfo()
    {
        string s = "";
        //s += "学区：" + CommonScore.GetAreaName;
        //s += " ";
        s += "学校：" + CommonScore.SchoolName;
        s += " ";
        s += "姓名：" + CommonScore.LogonStudent.StudentName;
        s += " ";
        s += "学号：" + CommonScore.LogonStudent.StudentCode;
        return s;
    }
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="schoolMark"></param>
    /// <returns></returns>
    [System.Web.Services.WebMethod]
    public static int UpdatePwd(string oldPwd, string newPwd)
    {
        //局级

        if (Common.GetUserInfo().UserType == 1 || Common.GetUserInfo().UserType == 2)
        {
            IEducationUsersLogic eduUserLogic = Container<IEducationUsersLogic>.Instance;

            Hashtable ht = new Hashtable();
            ht.Add("RID", Common.GetUserInfo().UID);
            ht.Add("Passwd", oldPwd);
            int iCount = eduUserLogic.FindCount(ht);

            if (iCount == 0) return -1;          //原密码不正确

            //重置密码
            List<int> list = new List<int>();
            list.Add(Common.GetUserInfo().UID);
            return eduUserLogic.ResetPwd(newPwd, list);
        }

        //校级
        if (Common.GetUserInfo().UserType == 3 || Common.GetUserInfo().UserType == 4)
        {
            ITeacherInfoLogic teacherLogic = Container<ITeacherInfoLogic>.Instance;

            Hashtable ht = new Hashtable();
            ht.Add("RID", Common.GetUserInfo().UID);
            ht.Add("Passwd", oldPwd);
            int iCount = teacherLogic.FindCount(ht);

            if (iCount == 0) return -1;          //原密码不正确

            //重置密码
            List<int> list = new List<int>();
            list.Add(Common.GetUserInfo().UID);
            return teacherLogic.ResetPassword(newPwd, list);
        }
        if (Common.GetUserInfo().UserType == 5)
        {
            IStudentInfoLogic teacherLogic = Container<IStudentInfoLogic>.Instance;

            Hashtable ht = new Hashtable();
            ht.Add("RID", Common.GetUserInfo().UID);
            ht.Add("Passwd", oldPwd);
            int iCount = teacherLogic.FindCount(ht);
            if (iCount == 0) return -1;          //原密码不正确
            //重置密码
            List<int> list = new List<int>();
            list.Add(Common.GetUserInfo().UID);
            return teacherLogic.ResetPassword(newPwd, list);
        }
        return 0;

    }

    protected string GetNowYearAndTerm
    {
        get
        {
            SchoolInfo si = SchoolCommon.Sch_SchoolInfo;
            return Common.ConvertYearAndTerm(si.SchoolYear, si.SchoolTerm);
        }
    }
}
